package com.class05;

import com.class05.ioc_01.ClientService;
import com.class05.ioc_01.ClientServiceImpl;
import com.class05.ioc_01.DefaultServiceLocator;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestPerson {
    @Test
    public void test() {
        ClassPathXmlApplicationContext classPathXmlApplicationContext
                = new ClassPathXmlApplicationContext("spring-01.xml");
        Person person = (Person) classPathXmlApplicationContext.getBean("person");
        Person person1 = (Person) classPathXmlApplicationContext.getBean("person");
//        除了八大基本类型，其他的都是引用类型，引用类型比较的是地址
        System.out.println(person == person1);
        person.setName("张三");
        person.setAge(18);
        System.out.println(person);
        ClientService clientService = (ClientService) classPathXmlApplicationContext.getBean("clientService");
        System.out.println(clientService);


        System.out.println("================================");
        //   自己创建对象
//     ClientServiceImpl clientService1 = new ClientServiceImpl();
//        相当于先创建工厂，然后通过工厂对象获取对象
        DefaultServiceLocator defaultServiceLocator = new DefaultServiceLocator();
        defaultServiceLocator.createClientServiceInstance();


    }

}
